﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _8模板方法模式
{
    /// <summary>
    /// 抽象模板
    /// </summary>
    abstract class AbstractClass
    {
        /// <summary>
        /// 抽象行为，到时候在子类中实现
        /// </summary>
        public abstract void PrimitiveOperation1();
        /// <summary>
        /// 抽象行为，到时候在子类中实现
        /// </summary>
        public abstract void PrimitiveOperation2();
        /// <summary>
        /// 模板方法，给出逻辑骨架，逻辑组成是一些相应的抽象操作，在子类中去实现
        /// </summary>
        public void TemplateMethod()
        {
            PrimitiveOperation1();
            PrimitiveOperation2();
            MessageBox.Show("");
        }
    }
    class ConcreteClassA:AbstractClass
    {
        public override void PrimitiveOperation1()
        {
            MessageBox.Show("具体类A方法1实现");
        }
        public override void PrimitiveOperation2()
        {
            MessageBox.Show("具体类A方法2实现");
        }
    }
    class ConcreteClassB : AbstractClass
    {
        public override void PrimitiveOperation1()
        {
            MessageBox.Show("具体类B方法1实现");
        }
        public override void PrimitiveOperation2()
        {
            MessageBox.Show("具体类B方法2实现");
        }
    }
}
